package com.itheima.a07regexdemo1;

public class RegexDemo7 {
    public static void main(String[] args) {
        //1.判断一个字符串的开始字符和结束字符是否一致，只考虑一个

        String regex1 ="(.).+\\1";

        System.out.println("a1234a".matches(regex1));
        System.out.println("a1234aba".matches(regex1));
        System.out.println("a123%$#4aba".matches(regex1));
        System.out.println("%a123%$#4aba".matches(regex1));

        //2.考虑多个
        System.out.println("-----------------------------");

        String regex2 ="(.+).+\\1";

        System.out.println("abc1234bc".matches(regex2));
        System.out.println("ababa1234abaab".matches(regex2));
        System.out.println("aa1a23%$#4abaa".matches(regex2));
        System.out.println("%a123%$#4aba".matches(regex2));

        //3.每一部分内的每一个字符也都要一样
        System.out.println("-----------------------------");

        String regex3 ="((.)\\2*).+\\1";
        System.out.println("abc1234abc".matches(regex3));
        System.out.println("ababa1234abaaa".matches(regex3));
        System.out.println("aa1a23%$#4abaa".matches(regex3));
        System.out.println("%a123%$#4aba".matches(regex3));

    }
}
